<?php

namespace App\Http\Controllers\Api;

use App\Http\Controllers\BaseController;
use Illuminate\Http\Request;

class RecommendController extends BaseController
{
    public $validate = [
        "add" => ["rules" => [
            "target_id" => "required|string|max:24",
            "target_type" => "required",
        ]],
        "cancel" => ["rules" => [
            "target_id" => "required|string|max:24",
            "target_type" => "required",
        ]],
    ];

    /**
     * @path /recommend/add
     * @category 用户推荐
     * @title 新增
     * @method POST
     * @params [{"name":"target_id","type":"text","required":1,"example":"","desc":"主体ID"},{"name":"target_type","type":"text","required":1,"example":"","desc":"主体类型"}]
     * @resBody {"success":true,"statusCode":200,"result":true,"message":"OK"}
     */
    public function add(Request $request)
    {
        $params = $request->all();

        $result = service()->UserRecommendService->createUserRecommend($this->getBaseInfo($params));

        return $this->apiReturn($result);
    }

    /**
     * @path /recommend/cancel
     * @category 用户推荐
     * @title 取消用户推荐
     * @method POST
     * @params [{"name":"target_id","type":"text","required":1,"example":"","desc":"主体ID"},{"name":"target_type","type":"text","required":1,"example":"","desc":"主体类型"}]
     * @resBody {"success":true,"statusCode":200,"result":true,"message":"OK"}
     */
    public function cancel(Request $request)
    {
        $params = $request->all();

        $result = service()->UserRecommendService->cancelUserRecommendByTargetId($this->getBaseInfo($params));

        return $this->apiReturn($result);
    }
}
